__author__ = 'Jason Crockett'

from http.server import HTTPServer, SimpleHTTPRequestHandler
import glob

header = open("./header.ini").read()
footer = open("./footer.ini").read()



class SpritzLocalServer:
    def __init__(self):
        self.PORT = 9014
        self.httpd = HTTPServer(('127.0.0.1', self.PORT), SimpleHTTPRequestHandler)
    def Start(self):
        print "serving at port", self.PORT
        self.httpd.serve_forever()

class Spritzer:
    def __init__(self):
        self.TextToSpritz = ""
        self.Name = "spritz" + str(len(glob.glob("*.html")) + 1) #count/number of html files in a folder + 1.
    def Update(self,head=header,foot=footer):
        self.SpritzFile = open(self.Name,'rw')
        self.NewSpritzFile = str(head) + self.TextToSpritz + str(foot)
        self.SpritzFile.write(self.NewSpritzFile)


